home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Taifun / Taifun 045 (1988-02-15)(Ossowski, Stefan)(DE)(PD).zip / Taifun 045 (1988-02-15)(Ossowski, Stefan)(DE)(PD).adf / Iff2Pcs / Source / flip.c < prev    next >
Text File  |  1988-01-20  |  3KB  |  148 lines

  1. /* Rotation code from Tomas Rokicki. In his words:
  2. **
  3. **  "The blitter would be much faster, as it turns out . . . 
  4. **   I even figured out how to do it, exactly, but
  5. **   I don't want to debug the blitter tonight . . ."
  6. */
  7.  
  8. /*
  9.  *   This code flips an 8 x 8 rectangle to the right 90 degrees.
  10.  *   Accompanying it is a set of routines which flip
  11.  *   a 128x128 section of the workbench screen (in the center.)
  12.  *   Note that the blitter could be up to 4 times faster (according
  13.  *   to my preliminary calculations), but it would probably also be
  14.  *   more complex, and this should be plenty fast.  Also, for small
  15.  *   rectangles like 16 x 16, this will certainly be faster.
  16.  */
  17. /*
  18.  *   This subroutine takes four arguments, two for the source and
  19.  *   two for the destination.  There is a pointer to the first byte
  20.  *   to be flipped, and the value to be added to the address for
  21.  *   each subsequent byte.
  22.  */
  23. flip(sp, sw, dp, dw)
  24. unsigned char *sp, *dp ;
  25. int sw, dw ;
  26. {
  27. /* 8(a5), 14(a5), 12(a5), 18(a5) */
  28. #asm
  29. ;
  30. ;   This subroutine actually flips the eight bytes in the lower byte
  31. ;   of d0-d7, and sticks the results in the upper bytes of d0-d7,
  32. ;   rotating their previous contents down.  Don't let the length of
  33. ;   it scare you; you might be able to discern a pattern in the
  34. ;   instructions.  It's really quite simple.
  35. ;
  36.     movem.w    reglist,-(sp)
  37.     move.l    8(a5),a0
  38.     move.w    12(a5),a1
  39.     move.b    (a0),d0
  40.     add.w    a1,a0
  41.     move.b    (a0),d1
  42.     add.w    a1,a0
  43.     move.b    (a0),d2
  44.     add.w    a1,a0
  45.     move.b    (a0),d3
  46.     add.w    a1,a0
  47.     move.b    (a0),d4
  48.     add.w    a1,a0
  49.     move.b    (a0),d5
  50.     add.w    a1,a0
  51.     move.b    (a0),d6
  52.     add.w    a1,a0
  53.     move.b    (a0),d7
  54.     roxr.b    #1,d0
  55.     roxr.w    #1,d0
  56.     roxr.w    #1,d1
  57.     roxr.w    #1,d0
  58.     roxr.w    #1,d2
  59.     roxr.w    #1,d0
  60.     roxr.w    #1,d3
  61.     roxr.w    #1,d0
  62.     roxr.w    #1,d4
  63.     roxr.w    #1,d0
  64.     roxr.w    #1,d5
  65.     roxr.w    #1,d0
  66.     roxr.w    #1,d6
  67.     roxr.w    #1,d0
  68.     roxr.w    #1,d7
  69.     roxl.w    #8,d0
  70.     roxr.b    #1,d1
  71.     roxr.w    #1,d1
  72.     roxr.w    #1,d2
  73.     roxr.w    #1,d1
  74.     roxr.w    #1,d3
  75.     roxr.w    #1,d1
  76.     roxr.w    #1,d4
  77.     roxr.w    #1,d1
  78.     roxr.w    #1,d5
  79.     roxr.w    #1,d1
  80.     roxr.w    #1,d6
  81.     roxr.w    #1,d1
  82.     roxr.w    #1,d7
  83.     roxl.w    #8,d1
  84.     roxr.b    #1,d2
  85.     roxr.w    #1,d2
  86.     roxr.w    #1,d3
  87.     roxr.w    #1,d2
  88.     roxr.w    #1,d4
  89.     roxr.w    #1,d2
  90.     roxr.w    #1,d5
  91.     roxr.w    #1,d2
  92.     roxr.w    #1,d6
  93.     roxr.w    #1,d2
  94.     roxr.w    #1,d7
  95.     roxl.w    #8,d2
  96.     roxr.b    #1,d3
  97.     roxr.w    #1,d3
  98.     roxr.w    #1,d4
  99.     roxr.w    #1,d3
  100.     roxr.w    #1,d5
  101.     roxr.w    #1,d3
  102.     roxr.w    #1,d6
  103.     roxr.w    #1,d3
  104.     roxr.w    #1,d7
  105.     roxl.w    #8,d3
  106.     roxr.b    #1,d4
  107.     roxr.w    #1,d4
  108.     roxr.w    #1,d5
  109.     roxr.w    #1,d4
  110.     roxr.w    #1,d6
  111.     roxr.w    #1,d4
  112.     roxr.w    #1,d7
  113.     roxl.w    #8,d4
  114.     roxr.b    #1,d5
  115.     roxr.w    #1,d5
  116.     roxr.w    #1,d6
  117.     roxr.w    #1,d5
  118.     roxr.w    #1,d7
  119.     roxl.w    #8,d5
  120.     roxr.b    #1,d6
  121.     roxr.w    #1,d6
  122.     roxr.w    #1,d7
  123.     roxl.w    #8,d6
  124.     roxr.b    #1,d7
  125.     roxl.w    #8,d7
  126.     move.l    14(a5),a0
  127.     move.w    18(a5),a1
  128.     move.b    d7,(a0)
  129.     add.w    a1,a0
  130.     move.b    d6,(a0)
  131.     add.w    a1,a0
  132.     move.b    d5,(a0)
  133.     add.w    a1,a0
  134.     move.b    d4,(a0)
  135.     add.w    a1,a0
  136.     move.b    d3,(a0)
  137.     add.w    a1,a0
  138.     move.b    d2,(a0)
  139.     add.w    a1,a0
  140.     move.b    d1,(a0)
  141.     add.w    a1,a0
  142.     move.b    d0,(a0)
  143.     movem.w    (sp)+,reglist
  144. reglist    reg    d0/d1/d2/d3/d4/d5/d6/d7/a0/a1
  145. #endasm
  146. }
  147.  
  148.